package cn.yeyu.org.service.impl;

import cn.yeyu.basic.util.PageList;
import cn.yeyu.org.domain.Department;
import cn.yeyu.org.mapper.DepartmentsMapper;
import cn.yeyu.org.query.DepartmentQuery;
import cn.yeyu.org.service.IDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class DepartmentServiceImpl implements IDepartmentService {

    @Autowired
    private DepartmentsMapper departmentsMapper;

    @Override
    public void save() {
        departmentsMapper.save();
    }

    @Override
    public void update() {
        departmentsMapper.update();
    }

    @Override
    public void delete() {
        departmentsMapper.delete();
    }

    @Override
    public Department loadById(Long id) {
        return departmentsMapper.loadById(id);
    }

    @Override
    public List<Department> loadAll() {
        return departmentsMapper.loadAll();
    }

    @Override
    public Long queryCount(DepartmentQuery query) {
        return departmentsMapper.queryCount(query);
    }

    @Override
    public PageList<Department> queryData(DepartmentQuery query) {
        Long total = departmentsMapper.queryCount(query);
        if (total==null || total.intValue()<1){
            return new PageList<>();
        }
        List<Department> list = departmentsMapper.queryData(query);

        return new PageList<>(total,list);
    }
    }



